package com.iqiju.guagua.photo.wx.mini.controller;

import com.iqiju.guagua.photo.wx.mini.common.Results;
import com.iqiju.guagua.photo.wx.mini.service.WxMiniFirstPageService;
import com.iqiju.guagua.photo.wx.mini.vo.FirstPageVO;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "首页接口")
@RequestMapping("/wx/photo/first/page")
public class FirstPageController {

    @Autowired
    private WxMiniFirstPageService wxMiniFirstPageService;


    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxMiniAppId",value = "微信小程序本地自定义id",required = true,dataType = "String",paramType = "path",example = "1192388834980298754"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 100, message = "参数错误，检查参数是否合法"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "首页查询接口", notes = "访问此接口，查询首页展示数据（连接+广告）")
    @GetMapping("{wxMiniAppId}")
    public Results<List<FirstPageVO>> selectFirstPageList(@PathVariable String wxMiniAppId){
        log.info("访问首页查询接口--------------------------------------------------");
        return wxMiniFirstPageService.selectFirstPageList(wxMiniAppId);
    }

}
